package com.mrrightli.week01;

import java.util.Base64;

public class HelloClassLoader extends ClassLoader {

    public static void main(String[] args) throws Exception {
        new HelloClassLoader().findClass("com.mrrightli.week01.Hello").newInstance();
    }

    @Override
    protected Class<?> findClass(String name) throws ClassNotFoundException {
        String helloBase64 = "yv66vgAAADQAQwoAEgAkCQAlACYIACcKACgAKQcAKggAKwgALAgALQgALgoABQAvCgARADAKACgAMQoAEQAyCgARADMKABEANAgANQcANgcANwEABjxpbml0PgEAAygpVgEABENvZGUBAA9MaW5lTnVtYmVyVGFibGUBAARtYWluAQAWKFtMamF2YS9sYW5nL1N0cmluZzspVgEADVN0YWNrTWFwVGFibGUHADgHADkBAANhZGQBAAUoSUkpSQEACHN1YnRyYWN0AQAIbXVsdGlwbHkBAAZkaXZpZGUBAAg8Y2xpbml0PgEAClNvdXJjZUZpbGUBAApIZWxsby5qYXZhDAATABQHADoMADsAPAEABUhlbGxvBwA9DAA+AD8BABBqYXZhL2xhbmcvU3RyaW5nAQABKwEAAS0BAAEqAQABLwwAQABBDAAcAB0MAD4AQgwAHgAdDAAfAB0MACAAHQEAGEhlbGxvIENsYXNzIEluaXRpYWxpemVkIQEAGmNvbS9tcnJpZ2h0bGkvd2VlazAxL0hlbGxvAQAQamF2YS9sYW5nL09iamVjdAEAE1tMamF2YS9sYW5nL1N0cmluZzsBAAJbSQEAEGphdmEvbGFuZy9TeXN0ZW0BAANvdXQBABVMamF2YS9pby9QcmludFN0cmVhbTsBABNqYXZhL2lvL1ByaW50U3RyZWFtAQAHcHJpbnRsbgEAFShMamF2YS9sYW5nL1N0cmluZzspVgEABmVxdWFscwEAFShMamF2YS9sYW5nL09iamVjdDspWgEABChJKVYAIQARABIAAAAAAAcAAQATABQAAQAVAAAAHQABAAEAAAAFKrcAAbEAAAABABYAAAAGAAEAAAADAAkAFwAYAAEAFQAAAUMABAAFAAAA0LIAAhIDtgAEB7wKWQMIT1kEEAZPWQUQB09ZBhAIT0wHvQAFWQMSBlNZBBIHU1kFEghTWQYSCVNNB7wKWQMET1kEBU9ZBQZPWQYHT04DNgQVBAeiAH0sFQQyEga2AAqZABSyAAIrFQQuLRUELrgAC7YADCwVBDISB7YACpkAFLIAAisVBC4tFQQuuAANtgAMLBUEMhIItgAKmQAUsgACKxUELi0VBC64AA62AAwsFQQyEgm2AAqZABSyAAIrFQQuLRUELrgAD7YADIQEAaf/g7EAAAACABYAAAA+AA8AAAAIAAgACQAfAAoAOAALAEwADgBVAA8AYQAQAHIAEgB+ABMAjwAVAJsAFgCsABgAuAAZAMkADgDPABwAGQAAAB0ABv8ATwAFBwAaBwAbBwAaBwAbAQAAIhwcHPoABQAJABwAHQABABUAAAAcAAIAAgAAAAQaG2CsAAAAAQAWAAAABgABAAAAIAAJAB4AHQABABUAAAAcAAIAAgAAAAQaG2SsAAAAAQAWAAAABgABAAAAJAAJAB8AHQABABUAAAAcAAIAAgAAAAQaG2isAAAAAQAWAAAABgABAAAAKAAJACAAHQABABUAAAAcAAIAAgAAAAQaG2ysAAAAAQAWAAAABgABAAAALAAIACEAFAABABUAAAAlAAIAAAAAAAmyAAISELYABLEAAAABABYAAAAKAAIAAAAFAAgABgABACIAAAACACM=";
        byte[] bytes = decode(helloBase64);
        return defineClass(name, bytes, 0, bytes.length);
    }

    public byte[] decode(String base64) {
        return Base64.getDecoder().decode(base64);
    }
}
